<template>
    <div class="app-container">
        <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch">
            <el-form-item label="姓名" prop="nickName">
                <el-input v-model="queryParams.nickName" placeholder="请输入姓名" clearable maxlength="10" show-word-limit
                    @keyup.enter.native="handleQuery" />
            </el-form-item>
            <el-form-item label="手机号" prop="phonenumber">
                <el-input v-model="queryParams.phonenumber" placeholder="请输入手机号" clearable maxlength="11"
                    show-word-limit @keyup.enter.native="handleQuery" />
            </el-form-item>
            <el-form-item label="企业" prop="enterpriseName">
                <el-select v-model="queryParams.enterpriseName">
               <el-option v-for="item in enterpriseData" :key="item.id" :value="item.enterpriseName" :label="item.enterpriseName">

               </el-option>
                </el-select>
            </el-form-item>
            
            <el-form-item>
                <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
                <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
            </el-form-item>
        </el-form>

        <el-row :gutter="10" class="mb8">
            <el-col :span="1.5">
                <el-button type="warning" icon="el-icon-download" size="mini" @click="handleExport"
                    v-hasPermi="['film:member:export']">导出</el-button>
            </el-col>
            <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
        </el-row>
        <el-table v-loading="loading" :data="configurationList" @selection-change="handleSelectionChange">
            <el-table-column type="selection" width="55" align="center" />
            <el-table-column label="序号" align="center" width="55" type="index" />
            <el-table-column label="姓名" align="center" prop="nickName" min-width="150" :show-overflow-tooltip="true" />
             <el-table-column label="用户名" align="center" prop="userName" min-width="150" :show-overflow-tooltip="true" />
          
            <el-table-column label="公司名称" align="center" prop="enterpriseName" min-width="200"
                :show-overflow-tooltip="true" />
            <el-table-column label="手机号" align="center" prop="phonenumber" min-width="150"
                :show-overflow-tooltip="true" />
            <el-table-column label="订单数" align="center" prop="orderCount" min-width="150"
                :show-overflow-tooltip="true" />
            <el-table-column label="已失效额度" align="center" prop="invalidAmount" min-width="100"
                :show-overflow-tooltip="true" />
            <el-table-column label="余额" align="center" prop="balance" min-width="100" :show-overflow-tooltip="true" />
            <el-table-column label="次卡余额" align="center" prop="secondaryCardBalance" min-width="100"
                :show-overflow-tooltip="true" />
            <el-table-column label="总额度" align="center" prop="totalAmount" min-width="100"
                :show-overflow-tooltip="true" />
            <el-table-column label="累计消耗现金" align="center" prop="totalConsumedCash" min-width="100"
                :show-overflow-tooltip="true" />
            <el-table-column label="已使用额度" align="center" prop="usedAmount" min-width="100"
                :show-overflow-tooltip="true" />
        </el-table>

        <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum"
            :limit.sync="queryParams.pageSize" @pagination="getList" />
    </div>
</template>

<script>
import { memberList ,enterpriseList1} from '@/api/film/member.js'
export default {
    name: "ConfigurationMember",
    data() {
        return {
            enterpriseData:[],
            // 遮罩层
            loading: true,
            // 选中数组q
            ids: [],
            // 非单个禁用
            single: true,
            // 非多个禁用
            multiple: true,
            // 显示搜索条件
            showSearch: true,
            // 总条数
            total: 0,
            // 配置维护表格数据
            configurationList: [],
            // 弹出层标题
            title: "",
            // 是否显示弹出层
            open: false,
            // 查询参数
            queryParams: {
                enterpriseName:undefined,
                nickName: undefined,
                pageNum: 1,
                pageSize: 10,
                phonenumber: undefined
            },
            // 表单参数
            form: {},
        };
    },
    created() {
        enterpriseList1().then(res=>{
            this.enterpriseData   = res.rows
        })
        this.getList();
    },
    methods: {
        /** 导出按钮操作 */
        handleExport() {
            this.download('/film/ticketOrder/exportMember', {
                ...this.queryParams,
                ids: this.ids
            }, `会员信息_${new Date().getTime()}.xlsx`)
        },
        /** 查询配置维护列表 */
        getList() {
            this.loading = true;
            memberList(this.queryParams).then(response => {
                this.configurationList = response.rows;
                this.total = response.total;
                this.loading = false;
            });
        },
        // 取消按钮
        cancel() {
            this.open = false;
            this.reset();
        },

        /** 搜索按钮操作 */
        handleQuery() {
            this.queryParams.pageNum = 1;
            this.getList();
        },
        /** 重置按钮操作 */
        resetQuery() {
            this.resetForm("queryForm");
            this.handleQuery();
        },
        // 多选框选中数据
        handleSelectionChange(selection) {
            this.ids = selection.map(item => item.userId)
            this.single = selection.length !== 1
            this.multiple = !selection.length
        }
    }
};
</script>
